package com.cheboohui.iqs.impl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.cheboohui.iqs.deal.BackDeal;
import com.cheboohui.iqs.deal.CheckDeal;
import com.cheboohui.iqs.deal.CustomizeDeal;
import com.cheboohui.iqs.deal.FrontDeal;
import com.cheboohui.iqs.deal.PriceDeal;
import com.cheboohui.iqs.service.Service;
import com.cheboohui.iqs.spring.entity.price.request.CheckCar;
import com.cheboohui.iqs.spring.entity.price.request.ConfirmInsured;
import com.cheboohui.iqs.spring.entity.price.request.PayRequest;
import com.cheboohui.iqs.spring.entity.price.request.PolicyRequest;
import com.cheboohui.iqs.spring.entity.price.request.PriceRequest;
import com.cheboohui.iqs.spring.entity.price.request.PriviousRequest;
import com.cheboohui.iqs.spring.entity.price.response.CheckCarResult;
import com.cheboohui.iqs.spring.entity.price.response.ConfirmInsuredResult;
import com.cheboohui.iqs.spring.entity.price.response.PriceResult;
import com.cheboohui.iqs.spring.entity.price.response.PriviousResult;

@org.springframework.stereotype.Service
public class ServiceImpl implements Service {
	/****************************** 报价 *************************************/

	/**
	 * 车辆查询
	 * 
	 * @param checkCar
	 *            请求参数
	 * @return
	 */
	@Override
	public CheckCarResult checkCar(CheckCar checkCar) {
		return PriceDeal.checkCar(checkCar);
	}

	/**
	 * 车险保费计算
	 * 
	 * @param priceRequest
	 *            请求参数
	 * @return
	 */
	@Override
	public PriceResult price(PriceRequest priceRequest) {
		return PriceDeal.carPrice(priceRequest);
	}

	/**
	 * 确认投保
	 * 
	 * @param confirmInsured
	 *            请求参数
	 * @return
	 */
	@Override
	public ConfirmInsuredResult confirm(ConfirmInsured confirmInsured) {
		return PriceDeal.confirm(confirmInsured);
	}

	/**
	 * 支付登记
	 * 
	 * @param payRequest
	 *            请求参数
	 * @return
	 */
	@Override
	public ConfirmInsuredResult pay(PayRequest payRequest) {
		return PriceDeal.pay(payRequest);
	}

	/****************************** 辅助查询接口 *************************************/

	/**
	 * 往年投保单查询
	 * 
	 * @param priviousRequest
	 *            请求参数
	 * @return
	 */
	@Override
	public PriviousResult privious(PriviousRequest priviousRequest) {
		return CheckDeal.privious(priviousRequest);
	}

	/**
	 * 保单相关查询
	 * 
	 * @param policyRequest
	 *            保单相关信息
	 * @param type
	 *            类型：01,投保单查询;02,保单查询
	 * @return
	 */
	@Override
	public PriviousResult policy(PolicyRequest policyRequest, String type) {
		return CheckDeal.policy(policyRequest, type);
	}

	/**
	 * 根据据投保单号查询单子状态
	 * 
	 * @param policyRequest
	 * @return
	 */
	@Override
	public ConfirmInsuredResult checkOrder(PolicyRequest policyRequest) {
		return CheckDeal.checkOrder(policyRequest);
	}

	/****************************** 保险公司回调接口 *************************************/

	/**
	 * 
	 * back:(统一回调处理). <br/>
	 * 
	 * @param type
	 *            0统一回调;1支付回调;2承保回调;3配送回调
	 * @param request
	 * @param response
	 */
	@Override
	public void back(HttpServletRequest request, HttpServletResponse response, int type) {
		BackDeal.back(request, response, type);
	}

	/****************************** 页面 *************************************/

	/**
	 * 根据需求获取页面(前端回调页面统一处理)
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@Override
	public ModelAndView getFront(HttpServletRequest request, HttpServletResponse response, String type) {
		return FrontDeal.getFront(request, response, type);
	}

	/****************************** 页面 *************************************/

	/**
	 * 自定义接口
	 * 
	 * @param request
	 * @param response
	 */
	@Override
	public void customize(HttpServletRequest request, HttpServletResponse response) {
		CustomizeDeal.customize(request, response);
	}
}
